package com.zhonghui.mes.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhonghui.common.annotation.Log;
import com.zhonghui.common.core.controller.BaseController;
import com.zhonghui.common.core.domain.AjaxResult;
import com.zhonghui.common.enums.BusinessType;
import com.zhonghui.mes.domain.MesZhiliangZuisu;
import com.zhonghui.mes.service.IMesZhiliangZuisuService;
import com.zhonghui.common.utils.poi.ExcelUtil;
import com.zhonghui.common.core.page.TableDataInfo;

/**
 * 制造执行MES—质量管理—质量追溯Controller
 * 
 * @author qiezi
 * @date 2023-12-15
 */
@RestController
@RequestMapping("/mes/zuisu")
public class MesZhiliangZuisuController extends BaseController
{
    @Autowired
    private IMesZhiliangZuisuService mesZhiliangZuisuService;

    /**
     * 查询制造执行MES—质量管理—质量追溯列表
     */
    @PreAuthorize("@ss.hasPermi('mes:zuisu:list')")
    @GetMapping("/list")
    public TableDataInfo list(MesZhiliangZuisu mesZhiliangZuisu)
    {
        startPage();
        List<MesZhiliangZuisu> list = mesZhiliangZuisuService.selectMesZhiliangZuisuList(mesZhiliangZuisu);
        return getDataTable(list);
    }

    /**
     * 导出制造执行MES—质量管理—质量追溯列表
     */
    @PreAuthorize("@ss.hasPermi('mes:zuisu:export')")
    @Log(title = "制造执行MES—质量管理—质量追溯", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MesZhiliangZuisu mesZhiliangZuisu)
    {
        List<MesZhiliangZuisu> list = mesZhiliangZuisuService.selectMesZhiliangZuisuList(mesZhiliangZuisu);
        ExcelUtil<MesZhiliangZuisu> util = new ExcelUtil<MesZhiliangZuisu>(MesZhiliangZuisu.class);
        util.exportExcel(response, list, "制造执行MES—质量管理—质量追溯数据");
    }

    /**
     * 获取制造执行MES—质量管理—质量追溯详细信息
     */
    @PreAuthorize("@ss.hasPermi('mes:zuisu:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(mesZhiliangZuisuService.selectMesZhiliangZuisuById(id));
    }

    /**
     * 新增制造执行MES—质量管理—质量追溯
     */
    @PreAuthorize("@ss.hasPermi('mes:zuisu:add')")
    @Log(title = "制造执行MES—质量管理—质量追溯", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MesZhiliangZuisu mesZhiliangZuisu)
    {
        return toAjax(mesZhiliangZuisuService.insertMesZhiliangZuisu(mesZhiliangZuisu));
    }

    /**
     * 修改制造执行MES—质量管理—质量追溯
     */
    @PreAuthorize("@ss.hasPermi('mes:zuisu:edit')")
    @Log(title = "制造执行MES—质量管理—质量追溯", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MesZhiliangZuisu mesZhiliangZuisu)
    {
        return toAjax(mesZhiliangZuisuService.updateMesZhiliangZuisu(mesZhiliangZuisu));
    }

    /**
     * 删除制造执行MES—质量管理—质量追溯
     */
    @PreAuthorize("@ss.hasPermi('mes:zuisu:remove')")
    @Log(title = "制造执行MES—质量管理—质量追溯", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mesZhiliangZuisuService.deleteMesZhiliangZuisuByIds(ids));
    }
}
